from django.conf.urls import url
from meiduo_admin.views import loginView
from rest_framework import routers
from meiduo_admin.views import indexView, userManage, skuView, spuView, specsView, specsOptionView, channelView, brandView, pictureView, orderView, authManageView, userGroupView, adminManageView


urlpatterns = [
    # 用户登录视图
    url(r"^authorizations/$",loginView.LoginView.as_view()),

    # 用户管理路由
    url(r"^users/$",userManage.UserView.as_view()),

    # sku路由
    url(r"^skus/$",skuView.SKUView.as_view({"get":"list","post":"create"})),
    url(r"^skus/(?P<pk>\d+)/$",skuView.SKUView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    url(r"^goods/simple/$",skuView.SPUSimpleView.as_view({"get":"list"})),
    url(r"^goods/(?P<pk>\d+)/specs/$",skuView.SPUSpecsView.as_view({"get":"list"})),
    # 三级分类路由
    url(r"^skus/categories/$",skuView.CategoriesView.as_view({"get":"list"})),

    # SPU路由
    url(r"^goods/$",spuView.SPUView.as_view({"get":"list","post":"create"})),
    url(r"goods/(?P<pk>\d+)/$",spuView.SPUView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    url(r"^goods/brands/simple/$",spuView.BrandView.as_view({"get":"list"})),
    # 频道查询路由
    url(r"^goods/channel/categories/$",spuView.GoodCategoryView.as_view({"get":"list"})),
    url(r"^goods/channel/categories/(?P<pk>\d+)/$",spuView.GoodCategoryView.as_view({"get":"list"})),

    # 规格管理路由
    url(r"^goods/specs/$",specsView.SpecsView.as_view({"get":"list","post":"create"})),
    url(r"^goods/specs/(?P<pk>\d+)/$",specsView.SpecsView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),

    #  规格选项管理
    url(r"^specs/options/$",specsOptionView.SpecOptionView.as_view({"get":"list","post":"create"})),
    url(r"^specs/options/(?P<pk>\d+)/$",specsOptionView.SpecOptionView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    url(r"^goods/specs/simple/$",specsOptionView.SpecNameView.as_view()),

    # 频道管理
    url(r"^goods/channels/$",channelView.GoodChannelView.as_view({"get":"list","post":"create"})),
    url(r"^goods/channels/(?P<pk>\d+)/$",channelView.GoodChannelView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    # 商品类别查询路由
    url(r"^goods/categories/$",spuView.GoodCategoryView.as_view({"get":"list"})),
    url(r"^goods/channel_types/$",channelView.ChannelGroupView.as_view()),

    # 品牌类别管理
    url(r"^goods/brands/$",brandView.BrandView.as_view({"get":"list","post":"create"})),
    url(r"^goods/brands/(?P<pk>\d+)/$",brandView.BrandView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),

    # 图片管理路由
    url(r"^skus/images/$",pictureView.PictureManageView.as_view({"get":"list","post":"create"})),
    url(r"^skus/images/(?P<pk>\d+)/$",pictureView.PictureManageView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    # SKU类别小视图
    url(r"^skus/simple/$",pictureView.SKUSimpleView.as_view()),

    # 订单管理
    url(r"^orders/$",orderView.OrderView.as_view({"get":"list"})),
    url(r"^orders/(?P<pk>\d+)/$",orderView.OrderView.as_view({"get":"retrieve",})),
    url(r"^orders/(?P<pk>\d+)/status/$",orderView.OrderView.as_view({"patch":"partial_update",})),

    # 权限管理
    url(r"^permission/perms/$",authManageView.PermissionView.as_view({"get":"list","post":"create"})),
    url(r"^permission/perms/(?P<pk>\d+)/$",authManageView.PermissionView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    url(r"^permission/content_types/$",authManageView.PermissionTypeView.as_view()),

    # 用户组管理
    url(r"^permission/groups/$",userGroupView.UserGroupView.as_view({"get":"list","post":"create"})),
    url(r"^permission/groups/(?P<pk>\d+)/$",userGroupView.UserGroupView.as_view({"delete":"destroy","get":"retrieve","put":"update"})),
    url(r"^permission/simple/$",authManageView.PermissionTypeView.as_view()),

    # 管理员管理
    url(r"^permission/admins/$",adminManageView.AdminManageView.as_view({"get":"list","post":"create"})),
    url(r"^permission/admins/(?P<pk>\d+)/$",adminManageView.AdminManageView.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    url(r"^permission/groups/simple/$",adminManageView.AdminPermissionSimpleView.as_view({"get":"list"})),
]

router = routers.SimpleRouter()
# 首页显示路由
router.register(prefix="statistical", viewset=indexView.IndexView,basename="home")
urlpatterns += router.urls
